package alibaba.ifelserefactor.demo01.test02;

import alibaba.ifelserefactor.demo01.ShareListener;
import alibaba.ifelserefactor.demo01.ShareType;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import static alibaba.ifelserefactor.demo01.ShareType.TYPE_LINK;

/**
 * @author ChangLiang
 * @date 2020/4/20
 */
@Slf4j
public class Link extends ShareItem {

    String title;
    String content;
    String link;

    public Link(ShareType link, String title, String content) {
        super(TYPE_LINK);
        // 上面每个子类的构造方法还对每个字段做了空值处理，
        // 为空的话，赋值default，这样如果用户传了空值，在调试就会发现问题
        this.title = !StringUtils.isEmpty(title) ? title : "default";
        this.content = !StringUtils.isEmpty(content) ? content : "default";
    }

    @Override
    public void doShare(ShareListener listener) {
        log.info("share link");
    }
}
